using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Finance.Web.Models.Mapping
{
    public class DepositMap : EntityTypeConfiguration<Deposit>
    {
        public DepositMap()
        {
            // Primary Key
            this.HasKey(t => t.Code);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(1024);

            this.Property(t => t.Info)
                .HasMaxLength(1024);

            // Table & Column Mappings
            this.ToTable("DEPOSIT");
            this.Property(t => t.Code).HasColumnName("DEPCODE");
            this.Property(t => t.Name).HasColumnName("NAME");
            this.Property(t => t.BankCode).HasColumnName("BANKCODE");
            this.Property(t => t.Info).HasColumnName("INFO");
            this.Property(t => t.Percent).HasColumnName("PERCENT");
            this.Property(t => t.Capitalization).HasColumnName("CAPITALIZATION");
            this.Property(t => t.PaymentFrequesny).HasColumnName("PAYMENFREQUENCY");
            this.Property(t => t.PeriodPayment).HasColumnName("PERIOD");
            this.Property(t => t.PercentAmountDepend).HasColumnName("PERCENTAMOUNTDEPEND");
            this.Property(t => t.HasPenalties).HasColumnName("HASPENALTIES");


            // Relationships
            this.HasOptional(t => t.Bank)
                .WithMany(t => t.Deposits)
                .HasForeignKey(d => d.BankCode);

        }
    }
}
